<script lang="ts">
import { defineComponent } from "vue";

export default defineComponent({
  props: {
    info: { type: Object, required: true },
  },
});
</script>

<template>
  <view class="group-item">
    <view class="group-item-wrapper">
      <image class="group-item-img" :src="info.group_pic" mode="aspectFill" />
      <view class="group-item-content">
        <view class="group-item-name">{{ info.name }}</view>
        <view style="display: flex; align-items: center">
          <view class="group-item-position">
            <image
              class="group-item-position2"
              src="@/package/community/static/group-position.png"
            />
            {{ info.area_name }}
          </view>
          <view class="group-item-user">
            <image
              class="group-item-user2"
              src="@/package/community/static/group-user.png"
            />
            {{ info.join_count }}人
          </view>
          <view class="group-item-tag">{{ info.cate_name }}</view>
        </view>
      </view>
    </view>
    <view class="group-item-desc" v-if="info.introduction">
      <image
        class="group-item-desc2"
        src="@/package/community/static/group-desc.png"
      />
      <view class="group-item-desc3">{{ info.introduction }}</view>
    </view>
    <view class="group-item-btn">加入</view>
    <view class="group-item-vip" v-if="info.is_vip === 1">VIP</view>
  </view>
</template>

<style lang="scss">
.group-item {
  position: relative;

  .group-item-wrapper {
    display: flex;
    align-items: center;
  }

  .group-item-img {
    width: 134rpx;
    height: 134rpx;
    border-radius: 20rpx;
  }

  .group-item-content {
    flex-grow: 1;
    min-width: 0;
    margin-left: 10rpx;
  }

  .group-item-name {
    max-height: 80rpx;
    min-height: 60rpx;
    padding-right: 118rpx;
    margin-bottom: 18rpx;
    font-size: 28rpx;
    color: #333333;
    line-height: 40rpx;
    display: -webkit-box;
    -webkit-box-orient: vertical;
    -webkit-line-clamp: 2;
    text-overflow: ellipsis;
    overflow: hidden;
  }

  .group-item-position,
  .group-item-user {
    display: flex;
    align-items: center;
    height: 36rpx;
    padding: 0 10rpx;
    margin-right: 10rpx;
    font-size: 20rpx;
    color: #999999;
    border-radius: 8rpx;
    background-color: #f8f8f8;
  }

  .group-item-position2,
  .group-item-user2 {
    width: 20rpx;
    height: 20rpx;
    margin-right: 2rpx;
  }

  .group-item-tag {
    padding: 0 14rpx;
    margin-left: 10rpx;
    font-size: 20rpx;
    color: #4e9b93;
    line-height: 32rpx;
    border-radius: 8rpx;
    border: 2rpx solid rgba(78, 155, 147, 0.2);
  }

  .group-item-desc {
    padding: 10rpx 20rpx 20rpx;
    margin-top: 20rpx;
    border-radius: 20rpx;
    background-color: #fbfbfb;
  }

  .group-item-desc2 {
    display: block;
    width: 24rpx;
    height: 14rpx;
    margin-bottom: 4rpx;
  }

  .group-item-desc3 {
    max-height: 64rpx;
    font-size: 22rpx;
    color: #999999;
    line-height: 32rpx;
    display: -webkit-box;
    -webkit-box-orient: vertical;
    -webkit-line-clamp: 2;
    text-overflow: ellipsis;
    overflow: hidden;
  }

  .group-item-btn {
    position: absolute;
    top: 4rpx;
    right: 0;
    width: 108rpx;
    font-size: 24rpx;
    color: #ffffff;
    line-height: 50rpx;
    text-align: center;
    border-radius: 28rpx;
    background-color: #ff7900;
  }

  .group-item-vip {
    position: absolute;
    left: 0;
    top: 0;
    padding: 0 16rpx;
    font-size: 20rpx;
    color: #ffffff;
    line-height: 28rpx;
    font-weight: bold;
    border-radius: 10rpx 0;
    background: linear-gradient(90deg, #ff9d06, #fe6703);
  }
}
</style>